#!/usr/bin/env python
# -*- coding:utf-8 -*-

import django
import os
import sys
from bug_manage import models

def run_django():
    base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    sys.path.append(base_dir)
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Automation_Test.settings")
    django.setup()

def run():
    exists = models.PricePolicy.objects.filter(category=1,title="个人免费版").exists()
    if not exists:
        models.PricePolicy.objects.create(
            category=1,
            title='个人免费版',
            price=0,
            project_num=3,
            project_member=2,
            project_space=20,
            per_file_size=5,
        )
    exists = models.PricePolicy.objects.filter(category=2, title="VIP").exists()
    if not exists:
        models.PricePolicy.objects.create(
            title='VIP',
            price=100,
            project_num=50,
            project_member=10,
            project_space=10,
            per_file_size=500,
            category=2
        )
    exists = models.PricePolicy.objects.filter(category=2,title="SVIP").exists()
    if not exists:
        models.PricePolicy.objects.create(
            title='SVIP',
            price=200,
            project_num=150,
            project_member=110,
            project_space=110,
            per_file_size=1024,
            category=2
        )
    exists = models.PricePolicy.objects.filter(category=2,title="SSVIP").exists()
    if not exists:
        models.PricePolicy.objects.create(
            title='SSVIP',
            price=500,
            project_num=550,
            project_member=510,
            project_space=510,
            per_file_size=2048,
            category=2
        )

if __name__ == '__main__':
    run_django()
    run()
    print('asd')
